package cloud.lysky.java.on.enumclass;

/**
 * @author luoly
 * @describe
 * @date 2022-11-14 16:58
 **/
enum Shrubbery {
    GROUND, CRAWLING, HAVING
}

public class EnumClass {
    public static void main(String[] args) {
        for (Shrubbery value: Shrubbery.values()){
            System.out.println(value + " ordinal:" + value.ordinal());
            System.out.println(value.compareTo(Shrubbery.CRAWLING) + " ");
            System.out.println(value.equals(Shrubbery.CRAWLING) + " ");

            System.out.println(value == Shrubbery.CRAWLING);
            System.out.println(value.getDeclaringClass());
            System.out.println(value.name());
            System.out.println("------------------------");
        }

        //根据字符串名获取一个枚举值
        for (String s : "HAVING CRAWLING GROUND".split(" ")) {
            Shrubbery eValue = Enum.valueOf(Shrubbery.class,s);
            System.out.println(eValue);
        }
    }
}
